// TypeScript file
class BigMovieClip extends egret.Sprite {

    private bmp:egret.Bitmap;
    private arr_texture=[];
    public currentFrame:number=0;
    private timer:egret.Timer;
    private loop:boolean;
    public constructor() {
        super();
        this.bmp=new egret.Bitmap();
        this.bmp.texture=RES.getRes('333_00000_png');
        this.bmp.width=1136;
        this.bmp.height=740;
        this.addChild(this.bmp);
        
    }
    public init(_arr_texture,_fps:number,_loop:boolean):void
    {
        this.loop=_loop;
        this.arr_texture=_arr_texture;
        this.timer=new egret.Timer(Math.floor(1000/_fps));
        this.timer.addEventListener(egret.TimerEvent.TIMER,this.update,this);
    }
    public gotoAndPlay(idx)
    {
        this.currentFrame=idx-1;
        this.bmp.texture=this.arr_texture[idx-1];
        this.timer.reset();
        this.timer.start();
    }
    public gotoAndStop(idx)
    {
        this.timer.reset();
        this.currentFrame=idx-1;
        this.bmp.texture=this.arr_texture[idx-1];
    }
    public stop()
    {
        this.timer.reset();
    }
    public play()
    {
        this.timer.reset();
        this.timer.start();
    }
    private update(e:egret.TimerEvent):void
    {
        // this._loop=false;
       
        this.currentFrame++;
        if(this.currentFrame>this.arr_texture.length-1)
        {
            if(this.loop)
            {
                this.currentFrame=0;
                this.bmp.texture=this.arr_texture[this.currentFrame];
            }
            else
            {
                this.stop();
                this.bmp.texture=this.arr_texture[this.currentFrame-1];
            }
        }
        else
        {
           this.bmp.texture=this.arr_texture[this.currentFrame];
        }
    }
}